package com.sccba.web.controller.yjcz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sccba.common.annotation.Log;
import com.sccba.common.core.controller.BaseController;
import com.sccba.common.core.domain.AjaxResult;
import com.sccba.common.core.page.TableDataInfo;
import com.sccba.common.enums.BusinessType;
import com.sccba.common.utils.poi.ExcelUtil;
import com.sccba.emtbusiness.domain.YjczFbChannel;
import com.sccba.emtbusiness.domain.YjczFbInfo;
import com.sccba.emtbusiness.service.IYjczChannelInfoService;
import com.sccba.emtbusiness.service.IYjczFbInfoService;
import com.sccba.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sccba.emtbusiness.domain.YjczFbChannelScene;
import com.sccba.emtbusiness.service.IYjczFbChannelSceneService;

/**
 * 应急处置流程Controller
 * 
 * @author lichh
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/yjcz/fbChannelScene")
public class YjczFbChannelSceneController extends BaseController
{
    @Autowired
    private IYjczFbChannelSceneService yjczFbChannelSceneService;

    @Autowired
    private IYjczFbInfoService yjczFbInfoService;

    @Autowired
    private IYjczChannelInfoService yjczChannelInfoService;
    
    /**
     * 查询应急处置流程列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjczFbChannelScene yjczFbChannelScene)
    {
        startPage();
        List<YjczFbChannelScene> list = yjczFbChannelSceneService.selectYjczFbChannelSceneList(yjczFbChannelScene);
        return getDataTable(list);
    }

    /**
     * 导出应急处置流程列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:export')")
    @Log(title = "应急处置流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjczFbChannelScene yjczFbChannelScene)
    {
        List<YjczFbChannelScene> list = yjczFbChannelSceneService.selectYjczFbChannelSceneList(yjczFbChannelScene);
        ExcelUtil<YjczFbChannelScene> util = new ExcelUtil<YjczFbChannelScene>(YjczFbChannelScene.class);
        util.exportExcel(response, list, "应急处置流程数据");
    }

    /**
     * 获取应急处置流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        YjczFbChannelScene fbChannelScene = yjczFbChannelSceneService.selectYjczFbChannelSceneByPkId(pkId);
        return success(fbChannelScene);
    }

    /**
     * 新增应急处置流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:add')")
    @Log(title = "应急处置流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjczFbChannelScene yjczFbChannelScene)
    {
        return toAjax(yjczFbChannelSceneService.insertYjczFbChannelScene(yjczFbChannelScene));
    }

    /**
     * 修改应急处置流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:edit')")
    @Log(title = "应急处置流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjczFbChannelScene yjczFbChannelScene)
    {
        return toAjax(yjczFbChannelSceneService.updateYjczFbChannelScene(yjczFbChannelScene));
    }

    /**
     * 删除应急处置流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:remove')")
    @Log(title = "应急处置流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(yjczFbChannelSceneService.deleteYjczFbChannelSceneByPkIds(pkIds));
    }

    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:list')")
    @GetMapping("/listFbInfo")
    public AjaxResult listFbInfo(YjczFbInfo yjczFbInfo)
    {
        return success(yjczFbInfoService.selectFbInfoList(yjczFbInfo));
    }

    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:list')")
    @GetMapping("/listChannelInfo/{fbId}")
    public AjaxResult listChannelInfo(@PathVariable("fbId") String fbId)
    {
        YjczFbChannel yjczFbChannel = new YjczFbChannel();
        yjczFbChannel.setFbId(Long.parseLong(fbId));
        return success(yjczChannelInfoService.selectChannelListByFbId(yjczFbChannel));
    }

    /**
     * 新增应急处置流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:add')")
    @Log(title = "应急处置流程", businessType = BusinessType.INSERT)
    @PostMapping("/addOrUpdateHandleProcess")
    public AjaxResult addOrUpdateHandleProcess(@RequestBody YjczFbChannelScene yjczFbChannelScene)
    {
        yjczFbChannelSceneService.addOrUpdateHandleProcess(yjczFbChannelScene);
        return success();
    }

}
